﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media;

using Aliphant.Mvvm.XEvent.UI;

namespace ModuleTest
{
    public class MainWindowViewModel : BindableBase
    {
        public MainWindowViewModel()
        {

            ResourceDictionary appResources = Application.Current.Resources;
            ResourceDictionary? targetDict = null;
            foreach (ResourceDictionary dict in appResources.MergedDictionaries)
            {
                if (dict.Source?.OriginalString?.EndsWith("Icons.xaml") == true)
                {
                    // 找到目标字典
                    targetDict = dict;
                    break;
                }
            }

            if (targetDict != null)
            {
                foreach (string item in targetDict.Keys)
                {
                    IconCollection.Add(new IconStruct
                    {
                        Key = item.Substring(5),
                        Data = (Geometry)targetDict[item]
                    });
                }
            }
        }

        public ObservableCollection<IconStruct> IconCollection { get; private set; } = new ObservableCollection<IconStruct>();


    }

    public class IconStruct : BindableBase
    {
        private string _key = string.Empty;
        public string Key { get => _key; set => SetProperty(ref _key, value); }

        private object? _data = null;
        public object? Data { get => _data; set => SetProperty(ref _data, value); }
    }
}
